package com.mdx.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mdx.bean.ControlGoodsBean;
import com.mdx.bean.DiseaseBean;
import com.mdx.dao.ControlGoodsDao;
import com.mdx.service.IControlGoodsService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class ControlGoodsServiceImpl extends ServiceImpl<ControlGoodsDao, ControlGoodsBean> implements IControlGoodsService {
    @Override
    public void addGoods(ControlGoodsBean controlGoodsBean) {
        this.save(controlGoodsBean);
    }

    @Override
    public IPage<ControlGoodsBean> findByItem(int pageNO, int pageSize, String cgName, String cgType, String goodsType) {
        IPage<ControlGoodsBean> page = new Page<>(pageNO,pageSize);
        QueryWrapper wrapper = new QueryWrapper<>();
        if (cgName != null && !cgName.equals("")){
            wrapper.like("f_cgName",cgName);
        }
        if (cgType != null && !cgType.equals("")){
            wrapper.like("f_cgType",cgType);
        }
        if (goodsType != null && !goodsType.equals("")){
            wrapper.like("f_goodsType",goodsType);
        }
        IPage<ControlGoodsBean> iPage = this.page(page,wrapper);
        return iPage;
    }
}
